package com.tanhua.manage.service;

import com.tanhua.domain.mongo.VoiceUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;

@Service
public class VoiceService {

    @Autowired
    private MongoTemplate mongoTemplate;

    public void reRemainingTimes() {

        Query query = new Query(Criteria.where("remainingTimes").lt(10));
        Update update = new Update();
        update.set("remainingTimes", 10);
        mongoTemplate.updateMulti(query, update, VoiceUser.class);
    }
}
